package com.trembear.ucarauth.controller;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

/**
 * @author Junwei.Xiong
 * @description:需要被保护的接口
 * @create 2018-07-10 11:53
 */
@RestController
public class AuthContorller {
    @GetMapping("/login")
    public String login() {
        //for debug
        return "login ";
    }
    @GetMapping("/product/{id}")
    public String getProduct(@PathVariable String id) {
        //for debug
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return "product id : " + id;
    }
    @GetMapping("/")
    public String defalut() {
        //for debug
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return "default page ";
    }

    @GetMapping("/order/{id}")
    public String getOrder(@PathVariable String id) {
        //for debug
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return "order id : " + id;
    }
}
